package org.tacademy.homework1;

import android.app.Activity;
import android.content.res.Resources;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ScrollView;

public class Homework1Activity extends Activity {
	
	ImageView imageView01;
	ImageView imageView02;
	ScrollView scrollView01;
	ScrollView scrollView02;
	
	
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        imageView01 = (ImageView)findViewById(R.id.imageView01);
        scrollView01 = (ScrollView)findViewById(R.id.scrollView01);
        scrollView01.setHorizontalFadingEdgeEnabled(true);
        
        imageView02 = (ImageView)findViewById(R.id.imageView02);
        scrollView02 = (ScrollView)findViewById(R.id.scrollView02);
        scrollView02.setHorizontalFadingEdgeEnabled(true);
        
        Resources res = getResources();
        BitmapDrawable bitmap = (BitmapDrawable)res.getDrawable(R.drawable.activity_lifecycle);
        
        int bitmapWidth = bitmap.getIntrinsicWidth();
        int bitmapHeight = bitmap.getIntrinsicHeight();
        
        imageView01.setImageDrawable(bitmap);
        imageView01.getLayoutParams().width = bitmapWidth;
        imageView01.getLayoutParams().height = bitmapHeight;
        
        imageView02.setImageDrawable(bitmap);
        imageView02.getLayoutParams().width = bitmapWidth;
        imageView02.getLayoutParams().height = bitmapHeight;
        
        
        Button downBtn = (Button)findViewById(R.id.downBtn);
        Button upBtn = (Button)findViewById(R.id.upBtn);
        
        downBtn.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				imageView01.setVisibility(View.INVISIBLE);
				imageView02.setVisibility(View.VISIBLE);
			}
		});
        
        upBtn.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				imageView01.setVisibility(View.VISIBLE);
				imageView02.setVisibility(View.INVISIBLE);
			}
		});
        
        
        
    }
}